﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BooksManager
{
    public partial class admin21 : Form
    {
        public admin21()
        {
            InitializeComponent();
        }

        private void button_add_Click(object sender, EventArgs e)
        {
            if(textBox_id.Text != "" && textBox_name.Text != "" && textBox_author.Text != "" && textBox_publish.Text != "" && textBox_amount.Text != "")
            {
                Dao dao = new Dao();
                string sql = $"insert into t_books values('{textBox_id.Text}','{textBox_name.Text}','{textBox_author.Text}','{textBox_publish.Text}',{textBox_amount.Text})";
                int n = dao.Execute(sql);
                if (n > 0)
                {
                    MessageBox.Show("添加成功");
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
                textBox_id.Text = "";
                textBox_name.Text = "";
                textBox_author.Text = "";
                textBox_publish.Text = "";
                textBox_amount.Text = "";   
            }
            else
            {
                MessageBox.Show("输入不要为空");
            }
           
        }
    }
}
